package com.ruoyi.web.controller.performance;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.performance.domain.AssessmentResult;
import com.ruoyi.performance.service.IAssessmentResultService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 教师考核结果Controller
 * 
 * @author eden
 * @date 2023-05-21
 */
@RestController
@RequestMapping("/performance/result")
public class AssessmentResultController extends BaseController
{
    @Resource
    private IAssessmentResultService assessmentResultService;

    /**
     * 查询教师考核结果列表
     */
    @PreAuthorize("@ss.hasPermi('performance:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(AssessmentResult assessmentResult)
    {
        startPage();
        List<AssessmentResult> list = assessmentResultService.selectAssessmentResultList(assessmentResult);
        return getDataTable(list);
    }

    /**
     * 导出教师考核结果列表
     */
    @PreAuthorize("@ss.hasPermi('performance:result:export')")
    @Log(title = "教师考核结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AssessmentResult assessmentResult)
    {
        List<AssessmentResult> list = assessmentResultService.selectAssessmentResultList(assessmentResult);
        ExcelUtil<AssessmentResult> util = new ExcelUtil<AssessmentResult>(AssessmentResult.class);
        util.exportExcel(response, list, "教师考核结果数据");
    }

    /**
     * 获取教师考核结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('performance:result:query')")
    @GetMapping(value = "/{Id}")
    public AjaxResult getInfo(@PathVariable("Id") Long Id)
    {
        return success(assessmentResultService.selectAssessmentResultById(Id));
    }

    /**
     * 新增教师考核结果
     */
    @PreAuthorize("@ss.hasPermi('performance:result:add')")
    @Log(title = "教师考核结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AssessmentResult assessmentResult)
    {
        return toAjax(assessmentResultService.insertAssessmentResult(assessmentResult));
    }

    /**
     * 修改教师考核结果
     */
    @PreAuthorize("@ss.hasPermi('performance:result:edit')")
    @Log(title = "教师考核结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AssessmentResult assessmentResult)
    {
        return toAjax(assessmentResultService.updateAssessmentResult(assessmentResult));
    }
    @PutMapping("/updata2")
    public AjaxResult updata2(@RequestBody List<AssessmentResult> resultListsult)
    {
        return toAjax(assessmentResultService.updata2(resultListsult));
    }




    /**
     * 删除教师考核结果
     */
    @PreAuthorize("@ss.hasPermi('performance:result:remove')")
    @Log(title = "教师考核结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Ids}")
    public AjaxResult remove(@PathVariable Long[] Ids)
    {
        return toAjax(assessmentResultService.deleteAssessmentResultByIds(Ids));
    }
}
